<?php


namespace App\Transformers\Live;


use App\Models\LiveAnchor;
use App\Models\LiveProduct;
use League\Fractal\TransformerAbstract;

class LiveProductTransformer extends TransformerAbstract
{
    public function transform(LiveProduct $data)
    {
        return [
            'id' => $data->id,
            'product_id' => $data->product_id ?? "",
            'audit_id' => $data->audit_id ?? "",
            'cover_url' => $data->cover_url ?? "",
            'price' => $data->price ?? "",
            'live_price' => $data->live_price ?? "",
            'url' => $data->url ?? "",
            'price_type' => $data->price_type ?? "",
            'price_type_text' => $data->priceTypeEnum[$data->price_type] ?? "",
            'cost_price' => $data->cost_price ?? "",
            'sort' => $data->sort ?? "",
            'is_show' => $data->is_show ?? 0,
            'audit_status' => $data->audit_status ?? "",
            'audit_status_text' => $data->auditStatusEnum[$data->audit_status] ?? "",
            'third_part_tag' => $data->third_part_tag ?? 0,
            'deleted_at' => $data->deleted_at ? $data->deleted_at->format("Y-m-d H:i:s") : "",
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : "",
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : "",
        ];
    }

}
